<?php
// 应用公共文件
//        getUrl是在common中封装的，封装样式如下
        function getUrl($url){
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($ch);
            curl_close($ch);
            $output = json_decode($output,true);
            return $output;
        }
//响应
if(!function_exists('responses')){
    function responses($code,$msg,$data)
    {
        return json([
            'code'=>$code,
            'msg'=>$msg,
            'data'=>$data
        ]);
    }
}
//成功
if(!function_exists('success')){
    function success($data,$code=200,$msg='')
    {
        return responses($code,$msg,$data);
    }
}
//失败
if(!function_exists('fail')){
    function fail($msg='',$code=500,$data=[])
    {
        return responses($code,$msg,$data);
    }
}

